package com.qiwx.pigeon.presenter;

import com.qiwx.pigeon.base.BasePresenter;
import com.qiwx.pigeon.base.IBaseView;
import com.qiwx.pigeon.data.network.ApiManager;
import com.qiwx.pigeon.data.network.BaseListResponse;
import com.qiwx.pigeon.data.network.BaseResponse;
import com.qiwx.pigeon.data.network.ResponseSubscriber;
import com.qiwx.pigeon.data.params.CageParam;
import com.qiwx.pigeon.data.params.FertilizeParam;
import com.qiwx.pigeon.data.vo.CageBeanVo;
import com.qiwx.pigeon.data.vo.CageRepairBean;
import com.qiwx.pigeon.data.vo.EliminateBean;
import com.qiwx.pigeon.data.vo.GoOutBean;
import com.qiwx.pigeon.data.vo.PairBean;
import com.qiwx.pigeon.data.vo.pageinfo.PageInfo;
import com.qiwx.pigeon.viewinterface.ICageRemindView;
import com.qiwx.pigeon.viewinterface.IGoOutView;

import java.lang.ref.WeakReference;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * @description
 * @Author qiwx
 * @Date 2020-04-26 09:59
 * 鸽笼提醒相关
 **/
public class CageRemindPresenter extends BasePresenter<ICageRemindView> {

    public CageRemindPresenter(WeakReference<ICageRemindView> from) {
        super(from);
    }

    public CageRemindPresenter(ICageRemindView from) {
        super(from);
    }

    //需要调窝
    public void queryCageChangeByPage(CageParam params) {
        ApiManager.getApiServer().queryCageChangeByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<CageBeanVo>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<CageBeanVo>> response) {
                        getView().onQueryCageSuccess(response.data);


                    }

                });
    }

    //空笼查询
    public void queryCageEmptyByPage(CageParam params) {
        ApiManager.getApiServer().queryCageEmptyByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<CageBeanVo>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<CageBeanVo>> response) {
                        getView().onQueryCageSuccess(response.data);


                    }

                });
    }

    // 查崽 提醒列表
    public void queryCageBabyByPage(CageParam params) {
        ApiManager.getApiServer().queryCageBabyByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<CageBeanVo>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<CageBeanVo>> response) {
                        getView().onQueryCageSuccess(response.data);


                    }

                });
    }

    // 查蛋提醒列表
    public void queryCageEggByPage(CageParam params) {
        ApiManager.getApiServer().queryCageEggByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<CageBeanVo>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<CageBeanVo>> response) {
                        getView().onQueryCageSuccess(response.data);


                    }

                });
    }

    //淘汰鸽笼列表
    public void queryCageEliminateByPage(CageParam params) {
        ApiManager.getApiServer().queryCageEliminateByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<EliminateBean>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<EliminateBean>> response) {
                        getView().onQueryEliminateBeanSuccess(response.data);


                    }

                });
    }
    //确认淘汰
    public void updateCageEliminate(EliminateBean params) {
        ApiManager.getApiServer().updateCageEliminate(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(1);


                    }

                });
    }


    //查询需要配对的鸽笼
    public void queryCagePairByPage(CageParam params) {
        ApiManager.getApiServer().queryCagePairByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<PairBean>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<PairBean>> response) {
                        getView().onQueryPairCageSuccess(response.data);


                    }

                });
    }


    // 鸽笼维修
    public void queryCageRepairByPage(CageParam params) {
        ApiManager.getApiServer().queryCageRepairByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<CageRepairBean>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<CageRepairBean>> response) {
                        getView().onQueryCageRepairSuccess(response.data);


                    }

                });
    }

    //更换鸽笼操作
    public void updateCageIsAdjust(CageParam params) {
        ApiManager.getApiServer().updateCageIsAdjust(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(1);
                    }

                });
    }

    //更新鸽笼 存栏状态
    public void updateCageCL(CageParam params) {
        ApiManager.getApiServer().updateCageCL(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(1);
                    }

                });
    }
    //更新鸽笼 空笼
    public void updateCageKL(CageParam params) {
        ApiManager.getApiServer().updateCageKL(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(2);
                    }

                });
    }

    //更新维修 存栏状态
    public void updateCageRepair(CageParam params) {
        ApiManager.getApiServer().updateCageRepair(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(1);
                    }

                });
    }

    //更新配对存栏状态
    public void updateCagePair(CageParam params) {
        ApiManager.getApiServer().updateCagePair(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(1);
                    }

                });
    }

    //更新查崽 存栏状态
    public void updateCageCZ(FertilizeParam params) {
        ApiManager.getApiServer().updateCageCZ(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse response) {
                        getView().onUpdateCageStatusSuccess(1);
                    }

                });
    }

    public void saveLayEgg(FertilizeParam params) {
        ApiManager.getApiServer().saveLayEgg(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<Integer>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<Integer> response) {
                        getView().onUpdateCageStatusSuccess(response.data);
                    }

                });
    }

    //配对
    public void makePair() {

    }

}
